package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.DTO.SysArchiveDTO;
import com.ruoyi.system.domain.DTO.SysArchivePageDTO;
import com.ruoyi.system.domain.SysArchiveFiles;
import com.ruoyi.system.service.SysArchiveFilesService;
import com.ruoyi.system.service.SysArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/archive")
public class SysArchiveController extends BaseController {
    @Autowired
    private SysArchiveService sysArchiveService;
    @Autowired
    private SysArchiveFilesService sysArchiveFilesService;


    /**
     * 分页列表查询
     * @param pageDTO
     * @return
     */
    @PostMapping("/page")
    public TableDataInfo page(@RequestBody SysArchivePageDTO pageDTO){
        return sysArchiveService.pageList(pageDTO);
    }

    /**
     * 档案信息新增
     * @param archiveDTO
     * @return
     */
    @PostMapping("/add")
    public AjaxResult saveArchive(@RequestBody SysArchiveDTO archiveDTO){
        sysArchiveService.addArchive(archiveDTO);
        return AjaxResult.success();
    }

    /**
     * 档案详情
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id){
        return AjaxResult.success(sysArchiveService.detail(id));
    }

    /**
     * 档案分类修改
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody SysArchiveFiles archiveFiles){
        sysArchiveFilesService.updateById(archiveFiles);
        return AjaxResult.success();
    }



}
